package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.Sms_Coupon_History_Mapper;
import com.shop.pojo.sms.Sms_Coupon_History;
import com.shop.service.Sms_Coupon_History_Service;
import com.shop.utils.LayuiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 优惠券领取历史信息-李贝贝
 */
@Service
public class Sms_Coupon_History_ServiceImpl implements Sms_Coupon_History_Service {

    @Autowired
    private Sms_Coupon_History_Mapper sms_coupon_history_mapper;

    /**
     * 显示所有优惠券领取历史信息
     */
    @Override
    public LayuiUtils<Sms_Coupon_History> find_sms_coupon_history(Page<Sms_Coupon_History> pages, Sms_Coupon_History sms_coupon_history) {
        LayuiUtils<Sms_Coupon_History> layuiUtils = new LayuiUtils<>();
        QueryWrapper<Sms_Coupon_History> queryWrapper = new QueryWrapper<>();
        if (sms_coupon_history.getCoupon_id() != null){
            queryWrapper.eq("coupon_id",sms_coupon_history.getCoupon_id());
        }
        Page<Sms_Coupon_History> sms_coupon_historyPage = sms_coupon_history_mapper.selectPage(pages,queryWrapper);
        layuiUtils.setCount(sms_coupon_historyPage.getTotal());
        layuiUtils.setData(sms_coupon_historyPage.getRecords());
        return layuiUtils;
    }
}
